<template>
  <div>
    <h1>查看Vue的过渡动画效果-设置具名动画</h1>
    <button @click="isShow = !isShow">控制元素的显示和隐藏</button>
    <transition name="one">
      <div class="text" v-show="isShow">我是动画1元素</div>
    </transition>
    <transition name="two">
      <div class="text" v-show="isShow">我是动画2元素</div>
    </transition>
  </div>
</template>

<script>
export default {
  name: "TransName",
  data() {
    return {
      isShow: true,
    };
  },
};
</script>

<style scoped>
.text {
  width: 200px;
  height: 50px;
  background: yellowgreen;
  font-size: 18px;
  text-align: center;
  line-height: 50px;
}

.one-enter,
.one-leave-to {
  opacity: 0;
  transform: translateX(300px) rotate(40deg);
}

.one-enter-active,
.one-leave-active {
  transition: all 1s linear;
}

.two-enter,
.two-leave-to {
  opacity: 0;
  transform: translateY(100px) rotate(-40deg);
}

.two-enter-active,
.two-leave-active {
  transition: all 1s linear;
}
</style>